﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;
namespace ContractManager.BLL.Business
{
    public static class ClsCapitals
    {
        public static List<Capitals> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.Capitals.Select(db);
            }
            
        }

        public static void Insert(Capitals capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<Capitals>(capital, EnumSaveMode.Requery);
            }
           
        }

        public static void Update(Capitals capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<Capitals>(capital);
            }
            
            
        }

        public static Capitals SelectByPk(Int32 capId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Capitals>(string.Format("CapId={0}", capId));
            }
            
        }

        public static Capitals SelectByCode(string capCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Capitals>(string.Format("CapCode='{0}'", capCode));
            }
            
        }

        public static int DeleteByPk(Int32 capId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<Capitals>(string.Format("CapId={0}", capId));
            }
            
        }
    }
}